package com.cedric.yixianpai.game.cards.Sects.swordCards.e_HuaShen;

import com.cedric.yixianpai.game.Constants.CardType;
import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Yun_LingBo extends SwordCard {
    private int x;//每连续用过1张云剑再加x防

    /**
     * title:云剑·凌波
     * effect:3x2/3/4攻 防+3/4/5 连云：每连续用过1张云剑再加3/4/5防
     */
    public Yun_LingBo(@Value("1") int lvl) {
        super("云剑·凌波");
        this.setLevel(lvl);
        this.setPeriod(Period.HUASHEN);
        this.setDescription("3攻x2/3/4 防+3/4/5 连云：每连续用过1张云剑再加3/4/5防");
        this.setCardType(CardType.YUN);

        this.setDamage(3);
        if (1 == lvl) {
            this.setCount(2);
            this.setShield(3);
            this.x = 3;
        } else if (2 == lvl) {
            this.setCount(3);
            this.setShield(4);
            this.x = 4;
        } else if (3 == lvl) {
            this.setCount(4);
            this.setShield(5);
            this.x = 5;
        } else {
            throw new RuntimeException("Card Level Error!");
        }
    }

    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        for (int i = 0; i < this.getCount(); i++) {
            Sta1.attack(Sta2, this.getDamage());
        }
        Sta1.getPlayerBuff().clearSwordIntent();
        Sta1.getPlayerBuff().addShield(this.getShield());
        if (Sta1.lastIs(CardType.YUN)) {
            int shd = Sta1.getPlayerBuff().getYun_Consecutive() * this.x;
            Sta1.getPlayerBuff().addShield(shd);
        }
        return true;
    }
}
